﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bindData_topNew();
            bindData_topLike();
        }
    }

    public void bindData_topNew()
    {
        string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
        SqlConnection conn = new SqlConnection(connStr);
        SqlCommand com = new SqlCommand();
        com.Connection = conn;
        com.CommandText = "sp_Top10DichVuMoiNhat";
        com.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = com;
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataList1.DataSource = ds.Tables[0].DefaultView;
        DataList1.DataBind();
    }

    public void bindData_topLike()
    {
        string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
        SqlConnection conn = new SqlConnection(connStr);
        SqlCommand com = new SqlCommand();
        com.Connection = conn;
        com.CommandText = "sp_Top10Like";
        com.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = com;
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataList2.DataSource = ds.Tables[0].DefaultView;
        DataList2.DataBind();
    }

    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName.Equals("MaDV"))
        {
            string MaDV = e.CommandArgument.ToString();
            Session["MaDV"] = MaDV;
            Response.Redirect("ChiTietDichVu.aspx#jump");
        }
    }
}